<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/include/background.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="<%=css%>/common.css"/>
<link rel="stylesheet" type="text/css" href="<%=css%>/main.css"/>
<title>修改密码</title>
<script>
$(document).ready(function(){
	//保存按钮
	$("#saveButton").click(function() {
		var originpassword = $.trim($("#originpassword").val());
		if(originpassword == ""){
			$("#originpassword_tip").html("请输入原始密码");
			return;
		}
		var password = $.trim($("#password").val());
		if(password == ""){
			$("#password_tip").html("请输入新密码");
			return;
		}
		var password2 = $("#password2").val();
		if(password2 == ""){
			$("#password2_tip").html("请输入确认密码");
			return;
		}	
		if(password != password2){
			$("#password2_tip").html("两次输入密码不一致");
			return;
		}
		originpassword = faultylabs.MD5(originpassword);
		password = faultylabs.MD5(password);
		//ajax提交
		$.ajax({
			url : "<%=pre%>/b_user/check<%=suf%>",
			type : 'post',
			dataType : 'html',
			data : {originpassword:originpassword,password:password},
			success : function(data, status) {
				if (status == 'success') {
					if (data == '1') {
						art.dialog.tips('<span style="color:#f00">修改成功！</span>', 1);	
					} else {
						art.dialog.tips('<span style="color:#f00">修改失败，检查原密码是否正确！</span>', 1);
					}
				}
			},
			error : function(xhr, textStatus,
					errorThrown) {
				art.dialog.tips('<span style="color:#f00">修改失败，检查原密码是否正确！</span>', 1);
			}
		});
	});
});
</script>
</head>
<body>
<div class="crumb-wrap">
	<div class="crumb-list">
		<i class="icon-font"></i>
		<a href="index.html">首页</a>
		<span class="crumb-step">&gt;</span>
		<span class="crumb-name">修改密码</span>
	</div>
</div>
<div class="result-wrap">
	<div class="result-content">
		<table class="insert-tab" width="100%">
			<tr>
				<td width="150px">原始密码：</td>
				<td>
					<input type="password" name="originpassword" id="originpassword">
					<span style="color:red" id="originpassword_tip"></span>
					</td>
			</tr>
			<tr>
				<td>新密码：</td>
				<td>
					<input type="password" name="password" id="password" >
					<span style="color:red" id="password_tip"></span>
				</td>
			</tr>
			<tr>
				<td>确认新密码：</td>
				<td>
					<input type="password" name="password2" id="password2" >
					<span style="color:red" id="password2_tip"></span>
				</td>
			</tr>
			<tr>
				<td>
					<input type="submit" value="保存修改" class="button" id="saveButton" />
				</td>
				<td></td>
			</tr>
		</table>
	</div>
</div>
</body>
</html>